// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
    env: "yiliaojiufeng-6gt0kj1l1df8b7b7",
    traceUser: true,
})

// 云函数入口函数

const db = cloud.database()
exports.main = async (event, context) => {
    var wxContext = cloud.getWXContext()
    try {
        return await db.collection('user_Star').add({
            // data 字段表示需新增的 JSON 数据
            data: {
                _openid: wxContext.OPENID,
                newsId: event._id,
            }
        })
    } catch (e) {
        console.error(e)
    }
}